/**
 * Copyright (c) 2008 Luciano Bustos - riaevolution.com, All Rights Reserved.
 * 
 * Contact luchyx@riaevolution.com
 * See www.riaevolution.com
 *  
 * Permission is hereby granted, free of charge, to any person obtaining a copy of 
 * this software and associated documentation files (the "Software"), to deal in 
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all 
 * copies or substantial portions of the Software.
 * 
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE. 
 * */
 
package com.riaevolution.cairngorm.view
{
	import flash.errors.IllegalOperationError;
	
	/**
	 * NotificableViewHelper allows you to create an abstract object that can handle 
	 * notifications submited by INotificableCommand.
	 * 
	 * 
	 * @author Luciano Bustos
	 * @see http://www.riaevolution.com
	 * 
	 */	
	public class NotificableViewHelper implements IViewNotificable
	{
		
		
		/**
		 * Internal view reference holds any kind of object. Preferently a UIComponent 
		 */
		private var _view:*;
		
		public function NotificableViewHelper(view:* = null):void {
			if(view) {
				_view = view;
			}
		}
		public function execute(action:String, data:Object):void {
			//TODO: implement function
			trace('execute::'+action);
			throw new IllegalOperationError('Implement execute() for '+this.view);
		}
		/**
		 * NotifyStatus allows you to call custom actions on the view in order to react in some different executions.
		 * 
		 * 
		 * @param type String a status type or common action that shoul change the current view.
		 * @param result Object custom object know by the implementation
		 * 
		 */		
		public function notifyStatus(type:String, result:Object):void
		{
			//TODO: implement function
			trace('notifyStatus::'+type);
		}
		
		public function notifyResult(result:Object):void
		{
			//TODO: implement function
			trace('notifyResult');
			throw new IllegalOperationError('Implement notifyResult() for '+this.view);
		}
		
		public function notifyFault(fault:Object):void
		{
			//TODO: implement function
			trace('notifyFault');
			throw new IllegalOperationError('Implement notifyFault() for '+this.view);
		}
		/**
		 * Override this method an set the return type to the view that use this NotificableViewHelper.
		 * This is usefull for compiler code hinting an strong typing.
		 * 
		 * @return UIComponent or any instance of you custom component.
		 * 
		 */		
		public function get view():* {
			return _view;
		}		
	}
}